ABC312 C - Invisible Hand
提出
WA
code: python
import bisect
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
# 1, 3
# 2, 2
# 1, 0
# 2, 0
# ....
# 5, 0
# 1, 1
lena = len(a)
lenb = len(b)
end = False
for i in range(lena):
bsize = lenb - bisect.bisect_left(b, ai) if i+1 >= bsize and bsize > 0:
end = True
exit()
if not end:
解答
code: python
from bisect import bisect_right, bisect_left
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.sort()
b.sort()
# print(a)
# print(b)
# 売り手過多の最小金額
# 120(3) -> 120, 10000
# 110(2) -> 120, 10000
# 90 (1) -> 100, 120, 10000
r, l = 10 ** 9 + 1, 0
while r - l > 1:
mid = (r + l) // 2
sell = bisect_right(a, mid)
buy = m - bisect_left(b, mid)
if sell >= buy:
r = mid
else:
l = mid
print(r)
テーマ
メモ
提出
WA
code: python
import bisect
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = sorted(list(map(int, input().split())))
# print(a)
# print(b)
# 売り手過多の最小金額
# 120(3) -> 120, 10000
# 110(2) -> 120, 10000
# 90 (1) -> 100, 120, 10000
ans = pow(10, 9)
sell_all = len(a)
buy_all = len(b)
for idx, v in enumerate(a):
sell = sell_all - idx
buy = buy_all - bisect.bisect_left(b, v)
if sell >= buy:
ans = min(ans, v)
print(ans)